﻿namespace Resharper.Abstractions.CodeDom.TypeMembers.Constructors
{
  using JetBrains.Annotations;
  using JetBrains.ReSharper.Psi.CSharp.Tree;
  using Resharper.Abstractions.CodeDom.TreeNodes;
  using Resharper.Abstractions.CodeDom.TypeMembers.Fields.Constants;

  /// <summary>Defines the <see cref="ConstantExtensions"/> class.</summary>
  public static class ConstructorExtensions
  {
    #region Public Methods

    /// <summary>Gets the method.</summary>
    /// <param name="treeNode">The tree node.</param>
    /// <returns>Returns the method.</returns>
    [CanBeNull]
    public static Constructor GetConstructor([NotNull] this TreeNode treeNode)
    {
      var constructor = treeNode.InternalTreeNode as IConstructorDeclaration;

      return constructor != null ? new Constructor(constructor) : null;
    }

    #endregion
  }
}